﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Core.Primitives
{
    [Serializable]
    public struct IntPosition
    {
        private int m_row;
        public int Row
        {
            get { return m_row; }
            set { m_row = value; }
        }

        private int m_column;
        public int Column
        {
            get { return m_column; }
            set { m_column = value; }
        }

        public IntPosition(int row, int col)
        {
            m_row = row;
            m_column = col;
        }        

        public override bool Equals(object obj)
        {
            if (obj is IntPosition)
            {
                IntPosition pos2 = (IntPosition)obj;

                return this.Row == pos2.Row && this.Column == pos2.Column;
            }

            return false;
        }
        public override int GetHashCode()
        {
            return m_row.GetHashCode() ^ m_column.GetHashCode();
        }
        public override string ToString()
        {
            return string.Format("({0}, {1})", m_row, m_column);
        }

        public static IntPosition operator +(IntPosition pos1, IntPosition pos2)
        {
            return new IntPosition(pos1.Row + pos2.Row, pos1.Column + pos2.Column);
        }
        public static IntPosition operator -(IntPosition pos1, IntPosition pos2)
        {
            return new IntPosition(pos1.Row - pos2.Row, pos1.Column - pos2.Column);
        }
    }
}
